package com.monkeybrother.thread.atomic;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.stream.IntStream;

/**
 * @Desc
 * @Author houry
 * @Date 2021/1/27 9:08
 **/
public class ThreadLocalTest {

    private static ThreadLocal<Integer> num = new ThreadLocal<>();
    private static CountDownLatch latch = new CountDownLatch(1);


    public static void main(String[] args) {
        IntStream.range(0, 10).forEach(v -> new Thread(() -> {
            try {
                latch.await();
                num.set(100);
                System.out.println(Thread.currentThread().getName() + " : num= " + num.get());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }).start());
        latch.countDown();



    }

}
